﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Jemgine.Engine.Scripts
{
    [Category("Physics"), Node]
   public class Push: Data.ScriptNode
    {
        public Vector2 Direction { get; set; }


       public Push()
       {
           AddInput("Fire", typeof(Physics));
           AddReference("Entity", typeof(Data.EntityRecord));
           AddOutput("Relay", null);
           Direction = new Vector2(1, 0);
       }

       public override void FireTerminal(int InputID, Data.ScriptPayload Payload)
       {
           var Object = ReferenceTerminals[0].GetTarget(Payload) as Data.EntityRecord;
           if (Object == null) return;
           var Physics = Object.GetComponent<Physics>();
           if (Physics != null && Physics.PhysicsBody != null)
               Physics.PhysicsBody.ApplyLinearImpulse(Direction, Physics.PhysicsBody.Position);
           OutputTerminals[0].Fire(Payload);
       }

      
    }
}
